﻿window.onload = function () {
    $("li").attr("class", "gay");
    $("img").click(function () {
        var flag = parseInt($(this).attr("typevalue"));
        $("#starCount").val(flag);
        var nextFlag = parseInt(flag + 1);
        for (var i = 1; i <= flag; i++) {
            $("#ImgStar" + i).attr("src", "/Content/Page/images/star_yellow.jpg");
        }
        for (var i = nextFlag; i <= 5; i++) {
            $("#ImgStar" + i).attr("src", "/Content/Page/images/star_gray.jpg");
        }
    });

}

$(document).ready(function (e) {
    var t9 = new PopupLayer({
        trigger: "#commid", popupBlk: "#starContain", closeBtn: "#closeButton", useOverlay: true, useFx: true,
        offsets: {
            x: 0,
            y: -41
        }
    });
    t9.doEffects = function (way) {
        if (way == "open") {
            this.popupLayer.css({ opacity: 0.3 }).show(400, function () {
                this.popupLayer.animate({
                    left: ($(document).width() - this.popupLayer.width()) / 2,
                    top: (document.documentElement.clientHeight - this.popupLayer.height()) / 2 ,
                    opacity: 0.8
                }, 1000, function () { this.popupLayer.css("opacity", 1) }.binding(this));
            }.binding(this));
        }
        else {
            this.popupLayer.animate({
                left: this.trigger.offset().left,
                top: this.trigger.offset().top,
                opacity: 0.1
            }, { duration: 500, complete: function () { this.popupLayer.css("opacity", 1); this.popupLayer.hide() }.binding(this) });
        }
    }


});
$(function () {
    $("#SubmitGrade").click(function () {
        //评分等级
        var grade = $("#starCount").val();
        //订单ID
        var orderid = getQueryStringByName("orderid");
        $.ajax({
            type: 'post',
            url: "/ComGrade/Add",
            data: { "orderid": orderid, "comGrade": grade },
            success: function (data) {
                if (data = "ok") {
                    alert("评级成功！");
                    $("#commid").hide();
                }
                else {
                    alert("评级失败！"+data);
                }
                $("#closeButton").click();
            },
            error: function (XMLHttpRequest, textStatus) {
            }
        });
    });
})